/*
 * @(#) JobEvaEntryAction.java Sep 14, 2011
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.jobeva.presentation.action;

import java.util.ArrayList;
import java.util.List;

import cn.strong.gweva.common.business.entity.ComboBoxEntity;
import cn.strong.gweva.common.business.service.ComboBoxService;
import cn.strong.gweva.common.presentation.action.AjaxBaseAction;
import cn.strong.gweva.jobeva.business.entity.JobEvaEntryEntity;
import cn.strong.gweva.jobeva.business.service.JobEvaEntryService;


/**
 * 岗位考核录入.
 * 
 * @author jincong
 * @version 1.0
 * @since Sep 14, 2011
 */
public class JobEvaEntryAction extends AjaxBaseAction
{

	/** serialVersionUID */
	private static final long serialVersionUID = -4606017958205001391L;

	/** 岗位考核录入entity */
	private JobEvaEntryEntity jobEvaEntryEntity;

	/** 岗位考核录入service */
	private JobEvaEntryService jobEvaEntryService;

	/** 下拉框service */
	private ComboBoxService comboBoxService;

	/** 岗位考核规则长度 */
	private int jobRuleSize;

	/**
	 * 岗位考核录入初始化.
	 * 
	 * @return
	 */
	public String add()
	{
		try
		{

			if (this.jobEvaEntryEntity != null && this.jobEvaEntryEntity.getItemId() != null)
			{
				this.jobEvaEntryEntity.setJobRuleList(this.jobEvaEntryService
						.searchJobRuleListByItemId(this.jobEvaEntryEntity.getItemId()));
			}
			else if (this.jobEvaEntryEntity != null)
			{
				this.jobEvaEntryEntity.setJobRuleList(null);
			}

			if (this.jobEvaEntryEntity != null && this.jobEvaEntryEntity.getJobRuleList() != null)
			{
				this.jobRuleSize = this.jobEvaEntryEntity.getJobRuleList().size();
			}
			else
			{
				this.jobRuleSize = 0;
			}
		}
		catch (Exception e)
		{
			return processException(e);
		}
		return ADD;
	}

	/**
	 * 岗位考核录入.
	 * 
	 * @return
	 */
	public String save()
	{

		try
		{
			this.jobEvaEntryEntity.setUpdateUserId(this.getLoginUser().getUserId());
			this.jobEvaEntryService.save(this.jobEvaEntryEntity);
			this.jobEvaEntryEntity = new JobEvaEntryEntity();
			this.setIsSuccess("保存成功！");
		}
		catch (Exception e)
		{
			return processException(e);
		}
		return ADD;
	}

	/**
	 * 设定岗位考核录入entity.
	 * 
	 * @param jobEvaEntryEntity 岗位考核录入entity
	 */
	public void setJobEvaEntryEntity(JobEvaEntryEntity jobEvaEntryEntity)
	{
		this.jobEvaEntryEntity = jobEvaEntryEntity;
	}

	/**
	 * 获取岗位考核录入entity.
	 * 
	 * @return 岗位考核录入entity
	 */
	public JobEvaEntryEntity getJobEvaEntryEntity()
	{
		return this.jobEvaEntryEntity;
	}

	/**
	 * 设定岗位考核录入service.
	 * 
	 * @param jobEvaEntryService 岗位考核录入service
	 */
	public void setJobEvaEntryService(JobEvaEntryService jobEvaEntryService)
	{
		this.jobEvaEntryService = jobEvaEntryService;
	}

	/**
	 * 获取岗位考核录入service.
	 * 
	 * @return 岗位考核录入service
	 */
	public JobEvaEntryService getJobEvaEntryService()
	{
		return this.jobEvaEntryService;
	}

	/**
	 * 设定下拉框service.
	 * 
	 * @param comboBoxService 下拉框service
	 */
	public void setComboBoxService(ComboBoxService comboBoxService)
	{
		this.comboBoxService = comboBoxService;
	}

	/**
	 * 获取下拉框service.
	 * 
	 * @return 下拉框service
	 */
	public ComboBoxService getComboBoxService()
	{
		return this.comboBoxService;
	}

	/**
	 * 设定岗位考核规则长度.
	 * 
	 * @param jobRuleSize 岗位考核规则长度
	 */
	public void setJobRuleSize(int jobRuleSize)
	{
		this.jobRuleSize = jobRuleSize;
	}

	/**
	 * 获取岗位考核规则长度.
	 * 
	 * @return 岗位考核规则长度
	 */
	public int getJobRuleSize()
	{
		return this.jobRuleSize;
	}

	/**
	 * 获取岗位列表.
	 * 
	 * @return 岗位列表
	 */
	public List<ComboBoxEntity> getJobList()
	{
		try
		{
			return this.comboBoxService.searchJobList();
		}
		catch (Exception e)
		{

		}

		return new ArrayList<ComboBoxEntity>();
	}

	/**
	 * 获取岗位考核项目列表.
	 * 
	 * @return 岗位考核项目列表
	 */
	public List<ComboBoxEntity> getJobItemList()
	{
		try
		{
			if (this.jobEvaEntryEntity != null && this.jobEvaEntryEntity.getJobId() != null)
			{
				return this.comboBoxService.searchJobItemList(this.jobEvaEntryEntity.getJobId());
			}
		}
		catch (Exception e)
		{

		}

		return new ArrayList<ComboBoxEntity>();
	}

}
